package com.nioEx;

import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.ServerSocket;
import java.nio.channels.SelectionKey;
import java.nio.channels.Selector;
import java.nio.channels.ServerSocketChannel;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;

public class SelectorEx {
	public static void main(String[] args) throws IOException {

		Selector selector = Selector.open();

		ServerSocketChannel sc = ServerSocketChannel.open();

		ServerSocket ss = sc.socket();
		sc.configureBlocking(false);
		InetSocketAddress address = new InetSocketAddress(80);
		sc.bind(address);

		SelectionKey key = sc.register(selector, SelectionKey.OP_ACCEPT);

		System.out.println("Going to listen on ");

		while (true) {
			if (selector.select() > 0) {
				Set<SelectionKey> keys = selector.selectedKeys();

				List<SelectionKey> keyList = new ArrayList<SelectionKey>(keys);

				for (SelectionKey selectionKey : keyList) {

				}
			}

		}
	}
}
